import { registerApplication, start } from "single-spa";

// registerApplication({
//   // 微应用名称 组织名称/微应用名称
//   name: "@single-spa/welcome",
//   //   返回值必须是promise
//   app: () =>
//     //   引入一个线上地址
//     System.import(
//       "https://unpkg.com/single-spa-welcome/dist/single-spa-welcome.js"
//     ),
//   // 激活路由
//   activeWhen: ["/"],
// });

registerApplication(
  "@single-spa/welcome",
  () => 
    System.import(
      "https://unpkg.com/single-spa-welcome/dist/single-spa-welcome.js"
    )
  ,
  (location) => location.pathname === "/"
);
registerApplication({
  name: "@fjyTeam/lagou",
  app: () => System.import("@fjyTeam/lagou"),
  activeWhen: ["/lagou"],
});

registerApplication({
    name: "@fjyTeam/vue-project",
    app: () => System.import("@fjyTeam/vue-project"),
    activeWhen: ["/vueProject"],
  });

// 启动微应用
start({
  // 是否可以通过history.pushState()和historyreplaceState()更改触发single-spa的路由
  // true 不允许 false 允许
  urlRerouteOnly: true,
});
